package de.bazinga.rotw.weapon.portal;

import com.jme.bounding.BoundingBox;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.Node;
import com.jme.scene.state.MaterialState;

import de.bazinga.rotw.game.Game;
import de.bazinga.rotw.model.Model;

public class Portal extends Node {
	private static final long serialVersionUID = 1L;
	
	protected Vector3f destLocation = new Vector3f(0,0,0);
	
	protected Node portal = null;
	
	public Portal() {
        super("Entry");
        
        // Load Portal Model
        portal = Model.loadModel(Portal.class.getClassLoader().getResource("portal.jme"), new Vector3f(0,0,0), 1);
        
        Quaternion rot180 = new Quaternion();
        rot180.fromAngleAxis(135, Vector3f.UNIT_Y);
        portal.setLocalRotation(rot180);
        
        portal.setLocalScale(1.2f);
        //portal.setLocalScale(new Vector3f(0.5f,0.3f,0.2f));
        
        
        MaterialState mat = Game.getGame().getDisplay().getRenderer().createMaterialState();
        mat.setAmbient(ColorRGBA.blue);
        mat.setDiffuse(ColorRGBA.blue);
        mat.setEmissive(ColorRGBA.blue);
        
        portal.setRenderState(mat);
        portal.updateRenderState();
        
        portal.setModelBound(new BoundingBox());
        portal.updateModelBound();
        
        this.attachChild(portal);
        

        this.setLocalTranslation(new Vector3f(0,-9999,0));
       
        this.setModelBound(new BoundingBox());
        this.updateModelBound();
        
        this.updateGeometricState(0, false);
	}
	
	
	/**
	 * Reset the Portal
	 */
	public void reset() {
		this.setLocalTranslation(new Vector3f(0,-9999,0));
	}
	
	
	public void setLocalTranslation(Vector3f loc) {
		super.setLocalTranslation(loc);
		this.updateGeometricState(0, false);
		//particleGeom.forceRespawn();
	}



	public Vector3f getDestLocation() {
		return destLocation;
	}



	public void setDestLocation(Vector3f destLocation) {
		this.destLocation = destLocation;
	}
}
